﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;

namespace capaNegocios
{
    public class clsSeguridad
    {
        clsConexion oClsConexion = new clsConexion();
        SqlConnection objConexion = new SqlConnection();
        
        public String usuario { get; set; }      

        public DataTable VerificarUsuario(String _tipoUsuario)
        {
            try
            {
                SqlCommand objComando = new SqlCommand();
                SqlDataAdapter objDataAdapter = new SqlDataAdapter();
                DataTable objDataTable = new DataTable();

                objConexion = oClsConexion.AbrirConexion();

                objComando.CommandType = CommandType.StoredProcedure;
                objComando.CommandText = "USP_S_VALIDARINGRESO";

                objComando.Parameters.Add(new SqlParameter("@ID", SqlDbType.Char));
                objComando.Parameters.Add(new SqlParameter("@TIPOUSUARIO", SqlDbType.Char));

                objComando.Parameters["@ID"].Value = this.usuario;
                objComando.Parameters["@TIPOUSUARIO"].Value = _tipoUsuario;

                objComando.Connection = objConexion;
                objComando.ExecuteNonQuery();

                objDataAdapter.SelectCommand = objComando;
                objDataAdapter.Fill(objDataTable);

                return objDataTable;
            }
            catch (SqlException ex)
            {
                return null;
                throw ex;
            }
            finally
            {
                objConexion.Close();
            }
        }
    }
}
